package com.cml.common.context;

import com.cml.common.config.Configuration;
import com.cml.domain.builder.ServerNodeBuilder;
import com.cml.domain.entity.ServerNode;
import com.cml.domain.service.ClientManagerService;
import com.cml.domain.service.ServerNodeManagerService;
import com.cml.domain.service.ServiceInstanceReplicasManagerService;
import com.cml.domain.service.SoltContextManagerService;
import com.cml.infrastructure.NetworkManager;

/**
 * 姓名：陈茂林
 * 时间：2023/11/8 8:36
 * 描述：
 */
public class ServerContext {
    private NetworkManager networkManager;

    private ServerNode serverNode = null;

    private SoltContextManagerService soltContextManagerService;

    private ClientManagerService serviceManagerService;

    private ServerNodeManagerService serverNodeManagerService;



    private Configuration configuration = Configuration.getInstance();

    public NetworkManager getNetworkManager() {
        return networkManager;
    }

    public ServerNode getServerNode() {
        return serverNode;
    }

    public SoltContextManagerService getSoltManagerService() {
        return soltContextManagerService;
    }

    public ClientManagerService getServiceManagerService() {
        return serviceManagerService;
    }

    public ServerNodeManagerService getServerNodeManagerService() {
        return serverNodeManagerService;
    }

    public Configuration getConfiguration() {
        return configuration;
    }

    public  static class Builder{
        private ServerContext serverContext;
        public Builder(){
            serverContext= new ServerContext();
            serverContext.networkManager= new NetworkManager(serverContext);
            serverContext.serverNode = new ServerNodeBuilder().build();
            serverContext.soltContextManagerService =new SoltContextManagerService(serverContext);
            serverContext.serviceManagerService=new ClientManagerService(serverContext);
            serverContext.serverNodeManagerService=new ServerNodeManagerService(serverContext);
        }

        public ServerContext build(){
            return serverContext;
        }

    }
}
